using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using UwinEducation.Domain.Entities;
using UwinEducation.Shared.Converters;
using UwinEducation.Shared.Enums;

namespace UwinEducation.Application.Dtos
{
    /// <summary>
    /// 学生课表DTO
    /// </summary>
    public class StudentScheduleDto
    {
        /// <summary>
        /// ID
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 学生ID
        /// </summary>
        public Guid StudentId { get; set; }

        /// <summary>
        /// 教师课表ID
        /// </summary>
        public Guid TeacherScheduleId { get; set; }

        /// <summary>
        /// 教师课表组ID
        /// </summary>
        public Guid TeacherScheduleGroupId { get; set; }

        /// <summary>
        /// 学号
        /// </summary>
        public string StudentNo { get; set; }

        /// <summary>
        /// 学生姓名
        /// </summary>
        public string StudentName { get; set; }

        /// <summary>
        /// 学校
        /// </summary>
        public string School { get; set; }

        /// <summary>
        /// 年级
        /// </summary>
        public GradeEnum? Grade { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remarks { get; set; }

        /// <summary>
        /// 课表状态
        /// </summary>
        public ScheduleStatus Status { get; set; }

        /// <summary>
        /// 废弃原因
        /// </summary>
        public string Reason { get; set; }



        /// <summary>
        /// 上课时间
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 下课时间
        /// </summary>
        public DateTime EndTime { get; set; }

    }

    public class StudentScheduleStatisticsDto
    {
        /// <summary>
        /// 学生ID
        /// </summary>
        public Guid StudentId { get; set; }
        /// <summary>
        /// 老师课程ID
        /// </summary>
        public Guid TeacherScheduleId { get; set; }
        /// <summary>
        /// 课程名称
        /// </summary>
        public string CourseName { get; set; }
        /// <summary>
        /// 教师名称
        /// </summary>
        public string TeacherName { get; set; }
        /// <summary>
        /// 课程单价
        /// </summary>
        public decimal CoursePrice { get; set; }
        /// <summary>
        /// 课程数量
        /// </summary>
        public int CourseCount { get; set; }
        /// <summary>
        /// 课程总价
        /// </summary>
        public decimal CourseTotalPrice { get; set; }
        /// <summary>
        /// 已支付金额
        /// </summary>
        public decimal PaidAmount { get; set; }

        //老师课表详情列表
        public List<TeacherScheduleDetailsDto> TeacherScheduleDetails  { get; set; }
    }

    /// <summary>
    /// 创建学生课表DTO
    /// </summary>
    public class CreateStudentScheduleDto
    {
        /// <summary>
        /// 学生ID
        /// </summary>
        public Guid StudentId { get; set; }

        /// <summary>
        /// 教师课表ID
        /// </summary>
        public Guid TeacherScheduleId { get; set; }

        /// <summary>
        /// 教师课表组ID
        /// </summary>
        public Guid TeacherScheduleGroupId { get; set; }

        /// <summary>
        /// 是否强制校验
        /// </summary>
        public bool IsForceCheck { get; set; }=true;

        /// <summary>
        /// 原因
        /// </summary>
        public string? Reason { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }



    }

    /// <summary>   
    /// 批量创建学生课表DTO
    /// </summary>
    public class CreateStudentScheduleRangeDto
    {
        /// <summary>
        /// 学生ID
        /// </summary>
        public Guid StudentId { get; set; }

        /// <summary>
        /// 教师课表组ID
        /// </summary>
        public Guid TeacherScheduleGroupId { get; set; }

        /// <summary>
        /// 是否强制校验
        /// </summary>
        public bool IsForceCheck { get; set; } = true;

        /// <summary>
        /// 学生课表列表
        /// </summary>
        public List<CreateStudentScheduleRangeModel> StudentSchedules { get; set; }
    }

    /// <summary>   
    /// 批量创建学生课表DTO
    /// </summary>
    public class CreateStudentScheduleRangeModel
    {
        /// <summary>
        /// 教师课表ID
        /// </summary>
        public Guid TeacherScheduleId { get; set; }

        /// <summary>
        /// 原因
        /// </summary>
        public string? Reason { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }
    }

        /// <summary>
        /// 学生课表列表
      
    /// <summary>
    /// 更新学生课表DTO
    /// </summary>
    public class UpdateStudentScheduleDto
    {
        /// <summary>
        /// ID
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 课表状态
        /// </summary>
        public ScheduleStatus? Status { get; set; }

        /// <summary>
        /// 废弃原因
        /// </summary>
        public string? Reason { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }
    }
    /// <summary>
    /// 日期范围请求参数
    /// </summary>
    public class DateRangeRequest
    {
        /// <summary>
        /// 学生ID
        /// </summary>
        public Guid StudentId { get; set; }

        /// <summary>
        /// 开始日期
        /// </summary>
        [JsonConverter(typeof(CustomDateTimeConverter))]
        public DateTime StartDate { get; set; }

        /// <summary>
        /// 结束日期
        /// </summary>
        [JsonConverter(typeof(CustomDateTimeConverter))]
        public DateTime EndDate { get; set; }
    }

    /// <summary>
    /// 学生课表列表
    /// </summary>
    public class StudentScheduleListDto
    {

        public Guid Id { get; set; }
        /// <summary>
        /// 上课时间
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 下课时间
        /// </summary>
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 课程对象
        /// </summary>
        public CourseDto Course { get; set; }

        /// <summary>
        /// 教室对象
        /// </summary>
        public ClassroomDto Classroom { get; set; }

        /// <summary>
        /// 教师对象
        /// </summary>
        public TeacherDto Teacher { get; set; }

       
        /// <summary>
        /// 状态
        /// </summary>
        public ScheduleStatus Status { get; set; }

        /// <summary>
        /// 废弃原因
        /// </summary>
        public string Reason { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public ScheduleStatus TeacherScheduleStatus { get; set; }

        /// <summary>
        /// 废弃原因
        /// </summary>
        public string TeacherScheduleReason { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remarks { get; set; }
    }

    /// <summary>
    /// 学生课表列表请求参数
    /// </summary>
    public class StudentScheduleListRequest
    {
        /// <summary>
        /// 学生ID
        /// </summary>
        [Required(ErrorMessage = "学生ID不能为空")]
        
        public Guid StudentId { get; set; }

        public Guid? TeacherScheduleId { get; set; }

        /// <summary>
        /// 开始日期
        /// </summary>
        [JsonConverter(typeof(CustomDateTimeConverter))]
        public DateTime? StartDate { get; set; }

        /// <summary>
        /// 结束日期
        /// </summary>
        [JsonConverter(typeof(CustomDateTimeConverter))]
        public DateTime? EndDate { get; set; }
    }

    /// <summary>
    /// 根据学生ID和教师课表ID删除学生课表请求参数
    /// </summary>
    public class DeleteByStudentIdAndTeacherScheduleIdRequest
    {
        /// <summary>
        /// 学生ID
        /// </summary>
        [Required(ErrorMessage = "学生ID不能为空")]
        public Guid StudentId { get; set; }

        /// <summary>
        /// 教师课表ID
        /// </summary>
        [Required(ErrorMessage = "教师课表ID不能为空")]
        public Guid TeacherScheduleId { get; set; }
    }
}